package com.filetransfer.utils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@Getter
@Slf4j
public class ThemeLoader {
    private final List<Class<?>> themeClasses = new ArrayList<>();
    public ThemeLoader() {
        loadThemes();
    }
    private void loadThemes() {
        String[] themeClassNames = {
                // 原生 FlatLaf 主题
                "com.formdev.flatlaf.FlatLightLaf",
                "com.formdev.flatlaf.FlatDarkLaf",
                "com.formdev.flatlaf.FlatIntelliJLaf",
                "com.formdev.flatlaf.FlatDarculaLaf",
                // IntelliJ Themes
                "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatMonokaiProIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme",
                "com.formdev.flatlaf.intellijthemes.FlatXcodeDarkIJTheme"
        };
        for (String className : themeClassNames) {
            try {
                Class<?> clazz = Class.forName(className);
                themeClasses.add(clazz);
            } catch (ClassNotFoundException e) {
                log.error("Failed to load theme class: {}", className, e);
            }
        }
    }
    public void applyTheme(Class<?> themeClass) throws Exception {
        Method setupMethod = themeClass.getMethod("setup");
        setupMethod.invoke(null);
    }
}
